<template>
  <div class="contact-us">
    <!-- 标题部分 -->
    <div class="name">
      <h1>联系我们</h1>
      <h3>contact-us</h3>
    </div>
    <!-- 卡片容器 -->
    <div class="box-wrap">
      <!-- 网址卡片 -->
      <el-card class="box-card">
          <img src="../../assets/internet.png" alt="网站图标" class="icon" />
          <div class="info-item">
            <div class="info-content">
              <p class="label">公司网址</p>
              <el-link
                type="primary"
                @click="openUrl(CompanyList[0].CompanyNetWork)"
              >
                {{ CompanyList[0].CompanyNetWork }}
              </el-link>
            </div>
          </div>
          <div class="qrcode">
            <el-image
              style="width: 87px; height: 87px"
              :src="CompanyList[0].WechatQRCode"
              fit="fill"
            />
        </div>
      </el-card>
      <!-- 电话卡片 -->
      <el-card class="box-card" style="width:360px">
          <img src="../../assets/phone.png" alt="电话图标" class="icon" />
          <div class="info-item">
            <div class="info-content">
              <p class="label">联系电话</p>
              <span>{{ CompanyList[0].Phone }}</span>
            </div>
          </div>
      </el-card>
      <!-- 地址卡片 -->
      <el-card class="box-card" style="width:495px">
          <img src="../../assets/location.png" alt="地址图标" class="icon" />
          <div class="info-item">
            <div class="info-content">
              <p class="label">公司地址</p>
              <span>{{ CompanyList[0].Address }}</span>
            </div>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
import { connrequest } from "@/api/firstPage";

export default {
  name: "contactUs",
  data() {
    return {
      CompanyList: [{}]
    };
  },
  created() {
    this.getData();
  },
  methods: {
    async getData() {
      try {
        const res = await connrequest("GetContactUS");
        this.CompanyList = res.Data;
      } catch (error) {
        console.log(error);
      }
    },
    openUrl(url) {
      window.open(url, "_blank");
    },
    copyAnswer(data) {
      let elInput = document.createElement("textarea");
      elInput.value = data;
      document.body.appendChild(elInput);
      elInput.select();
      this.$message.success("复制成功");
      document.execCommand("Copy");
      elInput.remove();
    },
    async translate() {
      // 翻译功能（未实现）
    }
  }
};
</script>

<style lang="scss" scoped>
.contact-us {
  width: calc(100vw - 230px);
  height: calc(100vh - 70px);
  overflow-y: auto;
  background: #fff;
  padding: 20px;
  margin: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;

  .name {
    position: relative;
    text-align: center;
    top:5%;
    h1 {
      margin: 0;
      font-size: 28px;
      font-weight: bold;
    }
    h3 {
      margin: 0 0 40px;
      font-size: 20px;
    }
  }

  .box-wrap {
    display: flex;
    width: 100%;
    justify-content: center;
    gap: 40px;
    margin-top: 5vh;
  }

  .box-card {
    width: 520px; /* 固定卡片宽度 */
    height: 180px; /* 固定卡片高度 */
    overflow: hidden;
    font-family: "微软雅黑";
  }
  /* 覆盖 el-card 的默认 body 样式 */
  ::v-deep .el-card__body {
    display: flex;
    flex-wrap: nowrap; /* 禁止换行 */
    align-items: center; /* 垂直居中 */
    justify-content: flex-start; /* 靠左对齐 */
    width: 100%; /* 占满卡片 */
    height: 100%; /* 占满卡片高度 */
    box-sizing: border-box; /* 内边距不影响宽度 */
  }
  .icon {
    width: 52px; /* 图标宽度 */
    height: 52px; /* 图标高度 */
    margin-right: 13px; /* 图标与文字的间距 */
    margin-left: 35px; /* 图标与文字的间距 */
  }
  .info-content {
    line-height: 1.5; /* 保持文字行高 */
    text-align: left; /* 文字向左对齐 */
    p {
      margin: 0; /* 移除段落默认外边距 */
      display: block; /* 强制span独占一行 */
      font-size: 20px;
      font-weight: bold;
    }
    .label{
      color: #333;
      font-size: 18px;
    }
    .el-link {
      display: block; /* 强制el-link独占一行 */
      margin-top: 5px; /* 添加一些间距，使两行更自然 */
      font-size: 18px;
    }
  }
  .qrcode {
    margin-left: 28px; /* 二维码靠右 */
  }
}
.night {
  .contact-us {
    background: #363b4d;
  }
  .el-card {
    background: #ccc;
    border:1px solid rgba(42, 77, 105, 0.5);
    background:inset 0 1px 2px rgba(255, 255, 255, 0.1);
  }
  .name{
    color: #ccc;
  }
}
</style>
